#include "GfxDriver/VertexStreamDecl.h"

namespace Orca {

	//--------------------------------------------------------------------------
	VertexStreamDecl::VertexStreamDecl(
		  VertexBuffer *vbuf
		, uint32 offsetInBytes
		, uint32 stride)
		
		: mOffset(0)
		, mVBuf(vbuf)
		, mOffsetInBytes(offsetInBytes)
		, mStride(stride) {

	}

	//--------------------------------------------------------------------------
	VertexStreamDecl::~VertexStreamDecl() {

	}

	//--------------------------------------------------------------------------
	void VertexStreamDecl::appendElement(const VertexElement &elem) {

		mElems.push_back(elem);

		mElems.back().offset = mOffset;
		mOffset += VertexElement::getElementSize(mElems.back().format);
	}

	//--------------------------------------------------------------------------
	VertexStreamDecl& VertexStreamDecl::operator << (const VertexElement &elem) {

		appendElement(elem);
		return *this;
	}

	//--------------------------------------------------------------------------
	void VertexStreamDecl::reset() {

		mElems.clear();
		mOffset = 0;
	}

	//--------------------------------------------------------------------------
}